package iedcyt.acute.dataAccess.factories;

import iedcyt.acute.dataAccess.dao.maauco.Au0Dao;

import iedcyt.acute.dataAccess.dao.maauco.Co0Dao;
import iedcyt.acute.dataAccess.dao.maauco.Ma0Dao;
import iedcyt.acute.dataAccess.dao.maauco.RPDao;
import iedcyt.acute.dataAccess.idao.IDao;
import iedcyt.acute.dataAccess.idao.maauco.IAu0Dao;

import iedcyt.acute.dataAccess.idao.maauco.ICo0Dao;
import iedcyt.acute.dataAccess.idao.maauco.IMa0Dao;
import iedcyt.acute.dataAccess.idao.maauco.IRPDao;
import iedcyt.acute.dataAccess.utils.BeansXML;
import iedcyt.acute.dataAccess.utils.Parameters;

import javax.security.auth.login.Configuration;

import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

public class AbsMAAUCOFactoryDao extends AbsFactoryDao {

	private static AbsMAAUCOFactoryDao _instance;

	private IAu0Dao _Au0Dao;
	private ICo0Dao _Co0Dao;
	private IMa0Dao _Ma0Dao;
	private IRPDao _RPDao;
	

	private AbsMAAUCOFactoryDao()
	{
		super();
		startDaos();
		
	}
	

	public static AbsMAAUCOFactoryDao getInstance()
	{
		if (_instance == null) _instance = new AbsMAAUCOFactoryDao();
		
		return _instance;
	}
	
	
	public IAu0Dao getAu0Dao()
	{
		return _Au0Dao;
	}
	
	
	public ICo0Dao getCo0Dao()
	{
		return  _Co0Dao;
	}
	
	
	public IMa0Dao getMa0Dao()
	{
		return  _Ma0Dao;
	}
	
	
	public IRPDao getRPDao()
	{
		return _RPDao;
	}
	
	@Override
	protected IDao getIDao() {
		return  _Ma0Dao;
	}


	/**
	 * @see iedcyt.acute.dataAccess.factories.AbsFactoryDao#startDaos()
	 */
	@Override
	public void startDaos() {
		AbstractApplicationContext _context = new FileSystemXmlApplicationContext(Parameters.get_instance().getBeanFile());
		_context.registerShutdownHook();
		
		_Au0Dao = (Au0Dao) _context.getBean("au0Dao");
		_Au0Dao.create();
		_Co0Dao = (Co0Dao) _context.getBean("co0Dao");
		_Co0Dao.create();
		_Ma0Dao= (Ma0Dao) _context.getBean("ma0Dao");
		_Ma0Dao.create();
		_RPDao= (RPDao) _context.getBean("rpDao");
		_RPDao.create();
	
		
	}
	
	/**
	 * @see iedcyt.acute.dataAccess.factories.AbsFactoryDao#getPath()
	 */
	@Override
	public String getPath() {
		return BeansXML.getInstance().getDatabasePath("MAAUCODataSource");
		
	}

	


	
}
